package com.example.testproj.thread_wait;

import java.util.ArrayList;
import java.util.List;

public class Producer extends Thread {
    List<Message> msgList=new ArrayList<>();

    @Override
    public void run() {
        super.run();
        try{
            while (true){
                Thread.sleep(3000);
                Message msg=new Message();
                synchronized (msgList){
                    msgList.add(msg);
                    msgList.notify();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
